/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package combomodel.empresa;

import eloma.classe.Cliente;
import eloma.classe.empresa.Empresa;
import java.util.List;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;

/**
 *
 * @author Icaro
 */
public class ComboBoxEmpresaModel extends AbstractListModel implements ComboBoxModel {

    private List<Empresa> listaEmpresa;
    private Empresa selection;

    public ComboBoxEmpresaModel(List<Empresa> listaEmpresa) {
        this.listaEmpresa = listaEmpresa;
    }

    @Override
    public int getSize() {
        return listaEmpresa.size();
    }

    @Override
    public Empresa getElementAt(int index) {
        return listaEmpresa.get(index);
    }

    @Override
    public void setSelectedItem(Object anItem) {
        selection = (Empresa) anItem;
    }

    @Override
    public Object getSelectedItem() {
        return selection;
    }

}
